var oIFrame = null;
function createIFrame() 
{
    var oIFrameElement = document.createElement("iframe");
    oIFrameElement.style.display = "none";
    oIFrameElement.name = "ifr_upload";
    oIFrameElement.id = "ifr_upload";
    document.body.appendChild(oIFrameElement);
    oIFrame = frames["ifr_upload"];
}

function checkIFrame() 
{
    if (!oIFrame)
    {
        createIFrame();       
    } 
    oIFrame.location = "upload";
}

function endUpload(result)
{
    if (result!="Error")
    {
        
    }
    else
    {
        //Do something after upload file
        
    }
}

function startUpload()
{
    //should be the index of upload form
    if (!oIFrame)
    {
        createIFrame();       
    }
    var oForm = $('upload_form');
    oForm.submit();
}